

function isValidUsername(form) {
    var username = form["j_username"].value;
    if(username == "" || username == null){
            return false;
    } 
    return true;
}

function isValidPassword(form) {
    var password = form["j_password"].value;
    if(password == "" || password == null){
            return false;
    } 
    return true;
}

function validate()
{
	isValid = new Boolean(true);
	var form = document.form;
	if(!isValidUsername(form)){
	    isValid = false;
	    document.getElementById("errorUsername").style.display='block';
	} else {
        document.getElementById("errorUsername").style.display='none';
    }
	
	if(!isValidPassword(form)){
	    isValid = false;
	    document.getElementById("errorPassword").style.display='block';
	} else {
        document.getElementById("errorPassword").style.display='none';
    }
	
	if(isValid == false){
	    event.preventDefault();
	    return false;
	}
	else
	{
		form.submit;
	}
}
